import java.util.Arrays;
import java.util.Scanner;

public class B {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n + 10];
		int[] b = new int[m + 10];
		int[] c = new int[n + m + 10];
		int[] mp = new int[100010];
		
		for(int i = 1; i <= n; i ++ ) {
			a[i] = sc.nextInt();
			c[i] = a[i];
			mp[a[i]] += 1;
		}
		for(int j = 1; j <= m; j ++ ) {
			b[j] = sc.nextInt();
			c[j + n] = b[j];
		}
		Arrays.sort(c, 1, n + m + 1);
		for(int i = 1; i <= n + m - 1; i ++ ) {
			if(mp[c[i]] != 0 && mp[c[i + 1]] != 0) {
				System.out.print("Yes");
				return;
			}
		}
		System.out.print("No");
		
	}
}
